<template>
  <div>
    <van-nav-bar title="我的关注" left-arrow @click-left="$router.go(-1)">
    </van-nav-bar>
    <Loading v-if="list == ''" />
    <div v-else class="warapp">
      <div class="box" v-for="(item, index) in list.list" :key="index">
        <img :src="item.avatar" alt="" />
        <div class="item-list">
          <span class="q1">{{ item.teacher_name }}</span>
          <span>{{ item.introduction }}</span>
        </div>
        <div class="box-text" @click="flag(item)">
          {{ flag === 2 ? "关注" : "取消关注" }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
import Loading from "../commponts/loading.vue";
import { collect, collectteacher1 } from "../../request/http";
export default {
  components: {
    Loading,
  },
  data() {
    return {
      list: [],
      flag1:[],
      pams: {
        page: 1,
        limit: 10,
        type: 2,
      },
    };
  },
  methods: {
    flag(v) {
        console.log(v);
      collectteacher1({collect_id:v.collect_id,type:2}).then((res) => {
        console.log(res);
        this.flag1 = res.data.flag;
        Toast.success(res.msg);
      });
    },
  },
  created() {
    collect(this.pams).then((res) => {
      console.log(res);
      this.list = res.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.warapp {
  background: rgb(242, 243, 245);
}
.box {
  margin: 0.4rem 0.267rem;
  height: 2.667rem;
  width: 95%;
  margin: 10px auto;
  background: #fff;
  border-radius: 10px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  img {
    width: 1.333rem;
    height: 1.333rem;
    margin: 0 0.267rem;
    border-radius: 100%;
  }
  .item-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    .q1 {
      font-size: 0.4rem;
    }
    span {
      color: #777;
    }
  }
  .box-text {
    width: 1.653rem;
    height: 0.747rem;
    margin-right: 50px;
    background: #ebeefe;
    border-radius: 0.4rem;
    text-align: center;
    line-height: 0.747rem;
    color: #eb6100;
  }
}
</style>